﻿using System;
using System.Threading.Tasks;

namespace DailyFx.UI
{
	public enum TaskKind
	{
 		// general background .
        Background,
        // clock .
        Periodic,
        // interrupt .
        Sporadic,
        // UI .
        LongRunning,
	}

    public class Taskimpl : Task //, IAsyncResult
    {
		/// <summary>
		///		the mode to schedule this task  .
		/// </summary>
		private TaskKind _mode ;

		/// <summary>
		///		the tick budget to run this task .
		/// </summary>
		private readonly double _budget;

		/// <summary>
		///		the deadline for this task to exit .
		/// </summary>
        private readonly DateTime _deadline;

	

		/// <summary>
		/// 
		/// </summary>
        public Taskimpl ( Action work, TaskKind mode, double budget ) 
			: base( work )
        {
			this._mode = mode;

			this._budget = budget;
            this._deadline = DateTime.UtcNow.AddMilliseconds( budget );

        }


		/// <summary>
		///		Gets the mode to schedule this task .
		/// </summary>
		public TaskKind TaskKind 
		{
			get { return this._mode; }
		}

		/// <summary>
		///		Gets the tick budget to run this task .
		/// </summary>
		public double Budget 
		{ 
			get { return this._budget; } 
		}

		/// <summary>
		///		Gets the deadline to end this task, if this is not long running .
		/// </summary>
		public DateTime Deadline
		{
			get { return this._deadline; }
		}

    }

}
